home *** CD-ROM | disk | FTP | other *** search
- import java.io.ByteArrayOutputStream;
- import java.io.DataOutputStream;
- import javax.microedition.rms.RecordStore;
-
- public class Library_Class {
- private String[] LibStringArray = new String[10];
- RecordStore theLibStore;
- String storeLibName;
- String StringName;
- int recordSize;
- boolean StoreExists = false;
- RecordStore FA_rs = null;
- String FIRST_AID_REC_STORE = "First_Aid_Store";
- String convertString1;
- String convertString2;
- String test;
-
- public boolean testRecStore(RecordStore var1, String var2) {
- this.storeLibName = var2;
- this.theLibStore = var1;
-
- try {
- this.theLibStore = RecordStore.openRecordStore(this.storeLibName, false);
- this.StoreExists = true;
- } catch (Exception var4) {
- this.StoreExists = false;
- }
-
- return this.StoreExists;
- }
-
- public void openRecStore(RecordStore var1, String var2) {
- this.storeLibName = var2;
- this.theLibStore = var1;
-
- try {
- this.theLibStore = RecordStore.openRecordStore(this.storeLibName, true);
- } catch (Exception var4) {
- System.out.println("Error : problem with creating store");
- }
-
- }
-
- public void writeData(String[] var1) {
- try {
- ByteArrayOutputStream var2 = new ByteArrayOutputStream();
- DataOutputStream var3 = new DataOutputStream(var2);
- boolean var5 = true;
-
- for(int var6 = 0; var6 < var1.length; ++var6) {
- var3.writeUTF(var1[var6]);
- var3.flush();
- byte[] var4 = var2.toByteArray();
- this.theLibStore.addRecord(var4, 0, var4.length);
- var2.reset();
- }
-
- var2.close();
- var3.close();
- } catch (Exception var7) {
- System.out.println(" there is an error in write streams1: " + var7);
- }
-
- }
-
- public void closeRecStore() {
- try {
- this.theLibStore.closeRecordStore();
- } catch (Exception var2) {
- System.out.println(" there is an error closing the RMS: " + var2);
- }
-
- }
-
- public void deleteRecStore() {
- if (RecordStore.listRecordStores() != null) {
- try {
- RecordStore.deleteRecordStore(this.storeLibName);
- System.out.println("deleting one ");
- } catch (Exception var2) {
- System.out.println(" there is an error in deleting the store: " + var2);
- }
- }
-
- }
-
- public String[] readDataNewA(int var1, int var2) {
- int var3 = var1;
- int var4 = var2;
-
- try {
- byte[] var5 = new byte[50];
- int var6 = -1;
-
- for(int var7 = var3; var7 <= var4; ++var7) {
- var5 = new byte[this.theLibStore.getRecordSize(var7)];
- this.theLibStore.getRecord(var7, var5, 0);
- this.convertString1 = new String(var5);
- this.convertString1 = this.convertString1.trim();
- if (this.convertString1.length() > 32) {
- this.convertString1 = this.convertString1.substring(1);
- }
-
- ++var6;
- this.LibStringArray[var6] = this.convertString1.trim();
- }
- } catch (Exception var8) {
- System.out.println(" there is an error in read streams: " + var8);
- }
-
- return this.LibStringArray;
- }
- }
-